﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Shapes;
using TimedTask.Models;
using Microsoft.Win32;
using TimedTask.Core;

namespace TimedTask.Views
{
    /// <summary>
    /// About.xaml 的交互逻辑
    /// </summary>
    public partial class About : Window
    {
        public About()
        {
            InitializeComponent();

            StringBuilder sbMsg = new StringBuilder();
            sbMsg.Append("版 本 号：V");
            sbMsg.Append(Helper.GetVersion() + "\r\n");
            sbMsg.Append("版权所有：m.sh.lin0328@163.com \r\n");
            sbMsg.Append("Copyright@ 2017 cnmmmss Right Reserved.\r\n");
            sbMsg.Append("作品说明：本作品只用于学习交流, 如若转载, 请注明作者与出处。");

            this.txtInfo.Text = sbMsg.ToString();
            this.btnClose.Click += (s, e) =>
            {
                base.Close();
            };
            this.btnOK.Click += (s, e) =>
            {
                base.Close();
            };
            this.btnAbout.Click += (s, e) =>
            {
                System.Diagnostics.Process.Start("notepad.exe", Const.StartPath + "\\" + "说明.txt");
            };
            this.MouseLeftButtonDown += (s, e) =>
            {
                if (e.LeftButton == MouseButtonState.Pressed)
                {
                    this.DragMove();
                }
            };
            this.btnLink.Click += (s, e) =>
            {
                if ((s as System.Windows.Documents.Hyperlink).CommandParameter != null)
                {
                    string link = (s as System.Windows.Documents.Hyperlink).CommandParameter.ToString();
                    try
                    {
                        System.Diagnostics.Process.Start("chrome.exe", link);
                    }
                    catch (Exception)
                    {
                        System.Diagnostics.Process.Start("iexplore.exe", link);
                    }
                }
            };
        }
    }
}
